//
//  EmoticonTextAttachment.swift
//  表情键盘
//
//  Created by 林柱强 on 16/2/28.
//  Copyright © 2016年 林柱强. All rights reserved.
//

import UIKit

class EmoticonTextAttachment: NSTextAttachment {
    //保存对应表情的文字
    var chs: String?
    
    class func imageText(emoticon: Emoticon, font: UIFont) -> NSAttributedString {
        //1.创建附件
        let  attachment = EmoticonTextAttachment()
        attachment.chs = emoticon.chs
        attachment.image = UIImage(contentsOfFile: emoticon.imagePath!)
        let size = font.lineHeight
        attachment.bounds = CGRectMake(0, -4, size, size)
        //2.创建图片属性字符串
        return NSAttributedString(attachment: attachment)
    }
}
